﻿<div class="d-flex align-items-center">
    <div class="me-1" style="width:16px;height:16px;border:1px solid black;@(BackgroundStyle)"></div>
    <span>@(!string.IsNullOrWhiteSpace(Color) ? Color : "(无)")</span>
</div>

@code {
    private string BackgroundStyle
    {
        get
        {
            if (!string.IsNullOrWhiteSpace(Color) && Color.StartsWith("#"))
            {
                return $"background-color:{Color};";
            }
            else
            {
                return "background-image:repeating-linear-gradient(45deg, #EFEFEF, #EFEFEF 3px, #FFF 3px, #FFF 6px);";
            }
        }
    }

    [Parameter]
    public string Color { get; set; }

    public static RenderFragment Create(string color)
    {
        return @<ColorRenderer Color="@color" />;
    }
}
